//
//  ScanView.swift
//  E-CycleForShop
//
//  Created by enghou on 17/3/3.
//  Copyright © 2017年 xyxorigation. All rights reserved.
//

import UIKit

class ScanView: UIView {
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.alpha = 0.3
        self.backgroundColor = UIColor.black
        let imageView = UIImageView.init()
        imageView.frame = CGRect.init(origin: CGPoint.init(x: 20 * YXWidthScale, y: 60 * YXHeightScale), size: CGSize.init(width: YXWidthScale, height: YXHeightScale))
        let image = UIImage.load(name: "nav_scan_close")
        imageView.image = image
        self.addSubview(imageView)
        let label = UILabel.init()
        let font = UIFont.systemFont(ofSize: 28 * YXWidthScale)
        let size = "二维码/条形码放入框内".StringSize(font: font)
        label.frame = CGRect.init(x: YXDeviceWidth / 2 - size.width / 2, y: YXDeviceHeight / 2 + YXDeviceWidth / 2 + 40 * YXHeightScale, width: size.width, height: 2 * size.height)
        label.textColor = UIColor.white
        label.numberOfLines = 2
        label.text = "二维码/条形码放入框内自动扫描"
        label.font = font
        self.addSubview(label)
    }
    
    private func trimView()->Void{
        let path = UIBezierPath.init(rect: self.bounds)
        let shape = CAShapeLayer.init()
        let rect = CGRect.init(x: YXDeviceWidth / 4, y: YXDeviceHeight / 2 - YXDeviceWidth / 4 , width: YXDeviceWidth / 2, height: YXDeviceWidth / 2)
        let bezier = UIBezierPath.init(rect: rect)
        path.append(bezier.reversing())
        shape.path = path.cgPath
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
